LEDs are small lights that come in a variety of sizes and colours. LED stands for Light Emitting Diode.
Diodes can only allow electricity to flow one way through them, so we need to make sure we connect them the right way around otherwise they won’t light up. The short leg should go to ground and the long leg to the digital signal>
Wire up the LED using a 220ohm resistor like this. The resistor limits the current so the LED does not burn out.
Circuit | Pico |
---|---|
Black | GND |
Blue | GP13 or another GP pin |
Write this code and download to the Pico. The LED should flash.
See code on github# Test blinking of an LED
import time
import board
import digitalio
# Set up the LED on pin 13 as a digital output pin
led = digitalio.DigitalInOut(board.GP13)
led.direction = digitalio.Direction.OUTPUT
# Loop forever, blinking the LED
while True:
led.value = True
time.sleep(0.5)
led.value = False
time.sleep(0.5)